# 写一个程序，测试此网络内,
# 192.168.1.1 ~  192.168.1.254 之间的机器，哪些开机，哪些关机

import subprocess

def ping(host_ip):
    cmd = 'ping -c2 %s &> /dev/null' % host_ip
    r = subprocess.run(cmd, shell=True)
    if r.returncode == 0:
        print(host_ip, '通')
    else:
        print(host_ip, '不通')

if __name__ == '__main__':
    for x in range(1, 255):
        ipv4 = '192.168.0.%s' % x
        ping(ipv4)